package com.smart.six.locale;

import java.text.MessageFormat;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 * 测试国际化信息格式化串
 *
 * @author junrui.wang
 * @create 2018/7/13
 */
public class Testi18nFormat {
    public static void main(String[] args) {
        ResourceBundle rb1 = ResourceBundle.getBundle("com/smart/six/locale/i18n/resource");
        ResourceBundle rb2 = ResourceBundle.getBundle("com/smart/six/locale/i18n/resource", Locale.US);
        ResourceBundle rb3 = ResourceBundle.getBundle("com/smart/six/locale/i18n/resource", Locale.CHINA);

        Object[] params = {"John", new GregorianCalendar().getTime()};

        String s1 = new MessageFormat(rb1.getString("common.common"), Locale.getDefault()).format(params);
        String s2 = new MessageFormat(rb2.getString("common.morning"), Locale.US).format(params);
        String s3 = new MessageFormat(rb3.getString("common.afternoon"), Locale.CHINA).format(params);

        System.out.println("default:" + s1);
        System.out.println("US:" + s2);
        System.out.println("China:" + s3);
    }
}
